'''###########################################################################################################################
### File: create_level.py
### Name: Patrick Delaney, Andrew Oberlin
### Class: CSE 487
### Instructor: Dr.Zmuda
### Assignment: Final Project
### Description: Class for saving and loading the objects
################
'''

from menu_button import MenuButton
from panda3d.core import Vec2, Point3, Vec3, Vec4
from direct.gui.DirectGui import *
import os
from pandac.PandaModules import TextNode
from panda3d.core import Filename
from general_information_level import GeneralInformationLevelGUI
#from level import Level

class LevelGenerator:
	'''
	### Name: __init__ (Constructor)
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Starts the process of creating a object
	'''
	def __init__(self, parent, project, levelGen, level):
		self.parent = parent
		self.levelGen = levelGen
		self.project = project
		self.level = level
		self.models = dict()
		self.__loadModels()
		
	'''
	### Name: __init__ (Constructor)
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Starts the process of creating a main character
	'''
	def __loadModels(self):
		self.models['background'] = self.parent.loader.loadModelCopy("models/plane")
		self.backgroundTexture = self.parent.loader.loadTexture("models/gui/game_maker/menu_background.jpg")
		self.models['background'].setTexture(self.backgroundTexture)
		self.models['background'].setTransparency(1)
		self.models['background'].setScale(2.67, 1, 2)
		self.models['background'].reparentTo(self.parent.base.aspect2d)
		
		## CHANGE LOGO HERE
		self.models['logo'] = self.parent.loader.loadModelCopy("models/plane")
		self.logoTexture = self.parent.loader.loadTexture("models/gui/game_maker/character_generator/character_generator_logo.png")
		self.models['logo'].setTexture(self.logoTexture)
		self.models['logo'].setTransparency(1)
		self.models['logo'].setScale(2.67, 1, 0.35)
		self.models['logo'].setPos(0, 0, 0.75)
		self.models['logo'].reparentTo(self.parent.base.aspect2d)
		
		self.models['general_information_gui'] = GeneralInformationLevelGUI(self.parent, self, self.level)
		
	'''
	### Name: nextStep
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Checks to see if the person has filled out the entire form
	###				 and then moves them to animating their character
	'''
	def nextStep(self):
		if (self.models['general_information_gui'].getNameText()):
			self.level.setName(self.models['general_information_gui'].getNameText())
		self.level.save(self.project)
		self.models['general_information_gui'].hide()
		self.levelGen.show()
		self.hide()
		self.levelGen.startLevelEdit()
		
	'''
	### Name: hide
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: hides this GUI
	'''
	def hide(self):
		for key in self.models.keys():
			self.models[key].hide()
			
	'''
		Destroys this gui
	'''
	def destroy(self):
		for key in self.models.keys():
			self.models[key].removeNode()